< previous page page_96 next page >

Page 96
With the advent of graphical, object-based operating systems such as Microsoft Windows and its successors, the way that users interact with programs has changed forever. Gone are the days when a character-based program ran from beginning to end with few user interactions. With Windows, you now have tremendous control over what functions a program performs, as well as the order in which these functions are performed. Although this concept made programs much easier to use, they can be much more difficult to develop. A program's developer is no longer in control of the entire program experience. Programmers of event-driven programs must plan for many possible user activities and, in many cases, must protect the users from themselves.
Windows applications are inherently event-driven, meaning that the flow of program execution is controlled by the events that occur as the program is running. As you'll see, most of these events are the direct result of actions initiated by the users; however, some events are invoked by other objects, including the program itself.
note.gif Although event-driven programs were around before Windows arrived on the scene (Macintosh programs and even a few DOS programs were event-driven), it was Windows that started the groundswell that has defined desktop computing today. square.gif

Introducing Events
The concept of an event-driven program might be fairly new to you, but the idea of responding to events should not be. Most of the world could be called event-driven. For example, consider your TV. You can change the channel whenever you feel like it, and with today's remote controls, you can go directly to your favorite channel instead of having to switch through all the channels on the TV. By the same token, you can change the volume of the TV whenever you want by as much as you want. You can probably also cut out the sound altogether by pressing the mute button. This type of control over how and when things happen correlates to event-driven programming. You (the user of your TV) initiate an event (by pressing a button) that causes the TV to take an action appropriate to the event that occurred. You also control when these events happen.
Windows programs work in a similar manner. In Microsoft Word, for example, you can easily change the font or style of a piece of text. You can also highlight a section of text and drag it to a new location. Each of these actions is made possible by the program's capability to take actions in response to user-initiated events.
As you create your own Windows programs, you will seek to model the program after the real-world tasks that the program is supposed to handle. Therefore, you should give the users command buttons or menu selections so that they can perform tasks when they want. Figure 5.1 shows an example of the interface for an event-driven program.

 
< previous page page_96 next page >